import Vue from 'vue'
import Router from 'vue-router'
import cookie from 'js-cookie'

Vue.use(Router);

const router =  new Router({
    mode: 'history',  routes: [
      {
        path: '/',
        name: 'all'
      }
    ]
  })

router.beforeEach((to, from, next) => {
    console.log("app login")
  if (to.path === '/login') {
        next()
  } else{
    if (cookie.get('en_token')) {next()
      } else {
        next({
          path: '/login'
        })
      }
  }
});

export default router
